# Maintainer: David Runge <dave@sleepmap.de>
_name=Piexif
pkgname=python-piexif
pkgver=1.1.3
pkgrel=8
pkgdesc="To simplify exif manipulations with python. Writing, reading, and more"
arch=('any')
url="https://github.com/hMatoba/Piexif"
license=('MIT')
depends=('python')
makedepends=('python-setuptools')
checkdepends=('python-pytest' 'python-pillow' 'libwebp' 'python-sphinx')
source=($pkgname-$pkgver.tar.gz::https://github.com/hMatoba/Piexif/archive/$pkgver.tar.gz
        pillow-7.2.patch)
sha512sums=('bae3a51603bf46e9a8170db180a298c70c77537cb405582eb53ade2b29907fbaeeb4d890a124e0a54de53077b7631c007be088c690f81fb3eda1cd3ccb1ca0d2'
            'be1ee541e3bb6c219d6fd9ab68e9143c2131f695a2001d36a0d63b0566d71a542a09d58dc0bcbdb8c1353297156ea7853d483b9a44407cb31c30acc4252310bf')

prepare() {
  cd "${_name}-${pkgver}"

  # https://github.com/hMatoba/Piexif/issues/108
  patch -Np1 -i ../pillow-7.2.patch
}

build() {
  cd "${_name}-${pkgver}"
  python setup.py build
}

check() {
  cd "${_name}-${pkgver}"
  export PYTHONPATH="build:${PYTHONPATH}"
  py.test
}

package() {
  cd "${_name}-${pkgver}"
  python setup.py install --skip-build \
    --optimize=1 \
    --prefix=/usr \
    --root="${pkgdir}"
  install -vDm 644 LICENSE.txt \
    "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -vDm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
}
